package com.supcon.exchangedata.repository.slave4;


import com.supcon.exchangedata.pojo.entity.mysql.operation.gj.BikeHireRestore;
import com.supcon.exchangedata.pojo.entity.mysql.operation.gj.TBusDailyAmount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *   公交自行车数据
 * @Author: yangbin
 * @Date: 2022/04/20/9:00
 * @Description:
 */
public interface SlaveGjOperationInfo1 extends JpaRepository<BikeHireRestore, Long> {


    @Transactional
    @Query(nativeQuery = true, value = "SELECT * FROM bike_hire_restore WHERE data_time = (SELECT MAX(data_time) FROM bike_hire_restore)")
    List<BikeHireRestore> findTopData();
    @Transactional
    @Query(nativeQuery = true, value = "SELECT SUM(restore_count) restore_count,sum(hire_count) hire_count,data_time,0 id from bike_hire_restore where data_time = (SELECT MAX(data_time) FROM bike_hire_restore) GROUP BY data_time")
    BikeHireRestore bikeOperation();


    @Transactional
    @Query(nativeQuery = true, value = "SELECT SUM(restore_count) restore_count,sum(hire_count) hire_count,data_time,tongid id from bike_hire_restore where data_time > ?1 and data_time <= ?2 GROUP BY data_time")
    List<BikeHireRestore> bikeOperationList(String startTime, String endTime);
}
